<?php
class Plugin_UserInfoPlugin extends Zend_Controller_Plugin_Abstract
{
	
	protected $_userinfo;
	
	public function preDispatch( Zend_Controller_Request_Abstract $request )
	{
		$response = $this->getResponse();
		
		if ( Zend_Auth::getInstance()->hasIdentity() ) {
			if (Zend_Session::namespaceIsset('Zend_Auth') ){
	    		$authSession = new Zend_Session_Namespace('Zend_Auth');
			}

			$userModel = new Model_DbTable_User();
			$user = $userModel->getUserInfo($authSession->userId);
			$this->_userinfo = "<ul>";
			$this->_userinfo .= "<li>id: " . $authSession->userId . "</li>";
			$this->_userinfo .= "<li>username: " . $user['username'] . "</li>"; 
			$this->_userinfo .= "<li>group: " . $user['userGroup'] . "</li>";
			$this->_userinfo .= "</ul>";
			
			
			$response->insert('userinfo', $this->_userinfo);
		} else {
			$response->insert('userinfo', '&nbsp;');
		}
	}
	
}